package com.wang.springbootinit.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wang.springbootinit.common.BaseResponse;
import com.wang.springbootinit.common.ErrorCode;
import com.wang.springbootinit.common.ResultUtils;
import com.wang.springbootinit.exception.BusinessException;
import com.wang.springbootinit.model.dto.excel.ExcelUpdateInfoDO;
import com.wang.springbootinit.model.entity.ExcelInfo;
import com.wang.springbootinit.model.param.BaseExcelInfoUpdate;
import com.wang.springbootinit.model.param.ExcelInfoUpdateParam;
import com.wang.springbootinit.model.vo.ExcelInfoVO;
import com.wang.springbootinit.service.ExcelInfoService;
import com.wang.springbootinit.utils.ExcelUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 对表格进行操作
 */
@RestController
@RequestMapping("/excel")
@Slf4j
public class ExcelOperateController {

    @Resource
    private ExcelInfoService excelInfoService;

    @ApiOperation("获取excel表格信息")
    @RequestMapping(value = "/getExcelInfo", method = RequestMethod.GET)
    public ExcelInfoVO getExcelInfo(Long chartId, HttpServletRequest request) {
        ExcelInfoVO excelInfoVO = excelInfoService.getExcelInfo(chartId, request);
        return excelInfoVO;
    }

    @ApiOperation("更新excel表格信息")
    @RequestMapping(value = "/updateExcelInfo", method = RequestMethod.POST)
    public BaseResponse<Boolean> updateExcelInfo(ExcelInfoUpdateParam excelInfoUpdateParam) {
        // todo 如何解决数据库多条数据保存回去的问题。
        Boolean result = excelInfoService.updateExcelInfo(excelInfoUpdateParam);
        return ResultUtils.success(result);
    }


}
